package com.homework;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
class TestAnimal {
    public static void main(String[] args) {
        Rabbit r = new Rabbit();
        r.setName("美人");
        r.setColor("黑色");
        r.setType("哺乳类");
        r.eat();
        r.cry();
        System.out.println("---------------------------------");
        Frog f = new Frog();
        f.setName("大兵");
        f.setColor("绿色");
        f.setType("非哺乳类");
        f.eat();
        f.cry();
        f.swiming();

    }
 }
class Rabbit extends Animal{

    @Override
    public void eat() {
        System.out.println("兔子是"+this.getType()+"，爱吃胡萝卜");
    }

    @Override
    public void cry() {
        System.out.println("那只"+this.getColor()+"的，名叫"+this.getName()+"的兔子正在叽叽的叫");
    }
}
class Frog extends Animal implements Ability{

    @Override
    public void eat() {
        System.out.println("青蛙是"+this.getType()+"，爱吃昆虫");
    }

    @Override
    public void cry() {
        System.out.println("那只"+this.getColor()+"的，名叫"+this.getName()+"的青蛙正在呱呱的叫");
    }

    @Override
    public void swiming() {
        System.out.println("虽然不是鱼，但青蛙也是泳坛高手！");
    }
}
interface Ability{
    void swiming();
}
abstract class Animal{
    private String name;
    private String color;
    private String type;
    public abstract void eat();

    public abstract void cry();

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return this.color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }
}